package com.xin.data.simbapesa.adapter;

import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.xin.data.simbapesa.R;
import com.xin.data.simbapesa.base.BaseBindingAdapter1;
import com.xin.data.simbapesa.databinding.SimbaSettingItemBinding;
import com.xin.data.simbapesa.utils.PhoneUtils;
import com.xin.data.simbapesa.utils.ResUtils;
import com.xin.data.simbapesa.utils.ViewUtils;

import java.util.List;

public class SettingAdapter extends BaseBindingAdapter1<String, SimbaSettingItemBinding> {


    public SettingAdapter(List<String> dataList) {
        super(dataList);
    }

    @Override
    protected void bindData(SimbaSettingItemBinding binding, String item, int position) {


        binding.tvTitle.setText(item);
        binding.tvDot.setVisibility(View.GONE);


        if (position == 0) {
            binding.tvRoot.setBackground(ResUtils.de(R.drawable.setting_item_bg1));
            binding.tvIcon1.setImageResource(R.mipmap.setting_icon1_1);
            binding.tvIcon2.setImageResource(R.mipmap.setting_icon1_2);
            binding.tvTitle.setTextColor(Color.parseColor("#7FBC67"));
        } else if (position == 1) {
            binding.tvRoot.setBackground(ResUtils.de(R.drawable.setting_item_bg2));
            binding.tvIcon1.setImageResource(R.mipmap.setting_icon2_1);
            binding.tvIcon2.setImageResource(R.mipmap.setting_icon2_2);
            binding.tvTitle.setTextColor(Color.parseColor("#7564B2"));
            if ((PhoneUtils.isUpdate(binding.getRoot().getContext()) || PhoneUtils.isForceUpdate(binding.getRoot().getContext()))) {
                binding.tvDot.setVisibility(View.VISIBLE);
            } else {
                binding.tvDot.setVisibility(View.GONE);
            }
        } else if (position == 2) {
            binding.tvRoot.setBackground(ResUtils.de(R.drawable.setting_item_bg3));
            binding.tvIcon1.setImageResource(R.mipmap.setting_icon3_1);
            binding.tvIcon2.setImageResource(R.mipmap.setting_icon3_2);
            binding.tvTitle.setTextColor(Color.parseColor("#EFBF77"));
        }

        binding.tvRoot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ViewUtils.viewScale(v);
                if (onBtnItemClickListener != null) {
                    onBtnItemClickListener.onItemClick(position);
                }
            }
        });

    }

    @Override
    protected int getItemType(String item) {
        return 0;
    }

    @Override
    protected SimbaSettingItemBinding createBinding(LayoutInflater inflater, ViewGroup parent, int viewType) {
        return SimbaSettingItemBinding.inflate(inflater, parent, false);
    }


}
